package com.library.service.impl;

import com.library.entity.Admin;
import com.library.mapper.AdminMapper;
import com.library.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    
    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin login(String username, String password) {
        return adminMapper.findByUsernameAndPassword(username, password);
    }

    @Override
    public List<Admin> findAllAdmins() {
        return adminMapper.findAll();
    }

    @Override
    public boolean addAdmin(Admin admin) {
        return adminMapper.insert(admin) > 0;
    }

    @Override
    public boolean updateAdmin(Admin admin) {
        return adminMapper.update(admin) > 0;
    }

    @Override
    public boolean deleteAdmin(Integer id) {
        return adminMapper.delete(id) > 0;
    }
} 